
import random


# 输出不对哦 M: -1
def output_value():
    for i in range(10):
        for j in range(10):
            print(array[i][j], end = " ")
        print()


def BinarySearch(searcharray,lower,upper,searchvalue):
    if upper >= lower:#这一行是有问题的
        mid = (lower + upper -1) // 2  # -1
        if searcharray[0][mid] == searchvalue:
            return mid
        else:
            if searcharray[0][mid] > searchvalue:
                return BinarySearch(searcharray,lower,mid - 1,searchvalue)
            else:
                return BinarySearch(searcharray,mid + 1,upper,searchvalue)
    return -1



if __name__ == '__main__':
    array = [[random.randint(1,100) for i in range(10)] for j in range(10)]
    arraylength = 10
    # M: -1
    for X in range(arraylength - 1): # M: -1
        for Y in range(arraylength - 2): # M: -1
            for Z in range(arraylength - Y -2):# M: -1
                if array[X][Z] > array[X][Z + 1]:
                    TempValue = array[X][Z + 1]
                    array[X][Z + 1] = TempValue
    output_value()
    # -1# -1
    print(BinarySearch(array, 0, 9, 68))
    print(BinarySearch(array, 0, 9, 101))#输入超过60的数字有很大的几率报more than 996 times recursion-1
